package com.crm.crm.controller;

import com.crm.crm.domain.dto.UserPageQueryParam;
import com.crm.crm.domain.vo.business.result.Result;
import com.crm.crm.domain.vo.business.result.TableDataInfo;
import com.crm.crm.domain.vo.login.TransferVo;
import com.crm.crm.service.TransferService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/transfer")
public class TransferController {

    @Autowired
    private TransferService transferService;
    @GetMapping("/list")
    public Result listInfo(UserPageQueryParam userPageQueryParam,@RequestParam Map<String, String> params){
        userPageQueryParam.setBeginTime(params.get("params[beginCreateTime]"));
        userPageQueryParam.setEndTime(params.get("params[endCreateTime]"));
        TableDataInfo<TransferVo> list = transferService.listInfo(userPageQueryParam);
        return Result.success().put("total",list.getTotal()).put("rows",list.getRows());
    }
    @PutMapping("/assignment/{type}/{ex}/{final}")
    public Result assignment(@PathVariable("type") Integer type
            ,@PathVariable("ex") Long ex
            ,@PathVariable("final") Long finalEx){
        transferService.assignment(type,ex,finalEx);
        return Result.success();
    }
}
